<template>
 <lay-layout class="Pop">

  <lay-body class="flexrow">
     
  <lay-form :model="model" ref="layFormRef" class="MainForm" >   
    <lay-form-item label="授权代码" prop="Code" required>
            <lay-input v-model="model.code"></lay-input>
          </lay-form-item>
<lay-form-item label="授权名称" prop="name" required>
            <lay-input v-model="model.name"></lay-input>
          </lay-form-item>
<lay-form-item label="Urls" prop="Urls" required>
            <lay-textarea v-model="model.Urls"></lay-textarea>
          </lay-form-item>
<lay-form-item label="备注" prop="memo" >
            <lay-input v-model="model.memo"></lay-input>
          </lay-form-item>
<!-- <lay-form-item label="参数1" prop="P1" >
            <lay-input v-model="model.P1"></lay-input>
          </lay-form-item>
<lay-form-item label="参数2" prop="P2" >
            <lay-input v-model="model.P2"></lay-input>
          </lay-form-item>
<lay-form-item label="参数3" prop="P3" >
            <lay-input v-model="model.P3"></lay-input>
          </lay-form-item>
<lay-form-item label="参数4" prop="P4" >
            <lay-input v-model="model.P4"></lay-input>
          </lay-form-item> -->
<lay-form-item label="排序号" prop=“sortno” >
            <lay-input v-model="model.sortno"></lay-input>
          </lay-form-item>

  </lay-form>
       
    </lay-body>
    <lay-footer>
     
      <lay-button size="sm" type="primary" @click="toSubmit"
            >保存</lay-button
          >
          <lay-button size="sm" @click="toCancel" style="margin-left:40px;">取消</lay-button>
    </lay-footer>
  </lay-layout>

</template>

<script lang="ts">
import { ref, watch,reactive,onMounted } from 'vue'
import { layer } from '@layui/layer-vue'
import MyHttp from "../../library/MyHttp";  
import MyWin from "../../library/MyWin"; 
import MyPage from "../../library/MyPage"; 
import {MyExcel} from "../../library/MyExcel"; 
import {MySimpleExport,TableColumn} from "../../library/MySimpleExport"; 
import MyData from "../../library/MyData"; 
import { number } from 'echarts';

export default {
  props:{
      data:Object
  },

  setup(prop:any, context:any) {
    const baseUrl="/htpage";
    const myWin=ref<any>(null);
    const model = reactive<any>(prop.data )
    const layFormRef = ref<any>()
    const toSubmit=async()=>{
      layFormRef.value.validate((isValidate:boolean, model:any, errors:Array<any>) => {
          if(!isValidate){
            let msg='';
            errors.forEach(element=>{ 
              msg+=`${element.message}
              `; 
            })
            
            MyWin.alert(msg,{});
            return;
          }
          save();
      });
    } 
    const toCancel=()=>{   
      context.emit("cancel");  
      myWin.value.close();
    }
    const save=async()=>{   
      context.emit("ok",model);   
    }

 
 
    onMounted(() =>{  
      myWin.value=new MyWin();
    });
    return {
      model,
      layFormRef,
      toSubmit,
      toCancel,
 

    }
  }
}
</script>
<style scoped>
.Pop .layui-footer,
.Pop .layui-header {
  height: 50px;
  text-align: center; 
  padding-top:10px;
}  
.Pop .layui-body{
  justify-content:start;
}
.MainForm{
  margin: 0px;
  width:95%;
}  
</style>